package com.example.springbootdemo.service;

import com.alibaba.fastjson.JSONObject;
import com.masiyi.simplecache.annotation.RedisCache;
import com.masiyi.simplecache.util.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Random;
import java.util.UUID;

/**
 * @Description TODO
 * @Author masiyi
 * @Date 2022/12/21
 **/
@Service
public class TestService {

    @Autowired
    RedisUtils redisUtils;

    @RedisCache(key = "test")
    public String test() {
        return UUID.randomUUID().toString();
    }

    public String testnocache() {
        return UUID.randomUUID().toString();
    }

    @RedisCache(key = "testParams",expire = 100)
    public Object testParams(String name, String sex) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(name, UUID.randomUUID());
        jsonObject.put(sex, new Random().nextInt(2));
        return jsonObject;
    }

}
